﻿<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title></title>
	<meta charset="utf-8" />
	<link href="../lib/highlight/default.css" rel="stylesheet" />
	<script src="../lib/highlight.js"></script>
	<script src="../lib/Coro.js"></script>
	<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>

	<h1>Output：</h1>
	<div id="console" style="border:1px solid #ddd; padding:20px; border-radius:20px;"></div>
	<script>
		var console = {
			log : function(msg){
				var div = document.createElement("div");
				div.innerText = msg;
				document.getElementById("console").appendChild(div);
			}
		}
	</script>

	<script>
asyn(function*(){
    for(var i = 0; i < 1000000; i++){
	    var j = 1 + 1;
		yield;
	}
	return "hello";
})().then(val=>{ console.log(val); });
	</script>



	<h1>Script：</h1>
<pre><code class="javascript">
//yield效率比await要高很多
asyn(function*(){
    for(var i = 0; i < 1000000; i++){
	    var j = 1 + 1;
		yield 0;
	}
	return "hello";
})().then(val=>{ console.log(val); });
</code></pre>

	

</body>
</html>
